/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK 1.6+
 * <p>
 * 版权所有(C)：江苏欧索软件有限公司
 * <p>
 * 公司名称：江苏欧索软件有限公司
 * <p>
 * 公司地址：中国苏州科技城青山路1号
 * <p>
 * 网址: http://www.oceansoft.com.cn
 * <p>
 * 作者: 090922(陈伟)
 * <p>
 * 文件名: com.oceansoft.mobile.econsole.modules.api.controller.ApiQueryController.java
 * <p>
 * 类产生时间: 2014-7-22 0022 下午 16:41
 * <p>
 * 负责人: 090922(陈伟)
 * <p>
 * Email:javacspring@gmail.com
 * <p>
 * 所在组 : 掌上公安应用平台
 * <p>
 * 所在部门: 开发部--手持技术部
 * <p>
 * <p>
 */
package com.oceansoft.mobile.econsole.modules.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Strings;
import com.oceansoft.mobile.econsole.common.constant.ConfigInfo;
import com.oceansoft.mobile.econsole.common.constant.Constant;
import com.oceansoft.mobile.econsole.common.util.StringUtils;
import com.oceansoft.mobile.econsole.modules.api.entity.*;
import com.oceansoft.mobile.econsole.modules.api.service.IMattersService;
import com.oceansoft.mobile.econsole.modules.api.service.IQueryService;
import com.oceansoft.mobile.econsole.modules.base.controller.BaseController;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.*;
import com.oceansoft.mobile.econsole.modules.jlapi.service.IJlApiService;
import com.oceansoft.mobile.econsole.modules.member.entity.WtMember;
import com.oceansoft.mobile.econsole.modules.member.service.IWtMemberService;
import com.oceansoft.mobile.econsole.vehicle.service.IVehicleService;
import com.oceansoft.mobile.econsole.webservice.securitystaff.SecurityStaffService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Objects;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * 查询服务
 *
 * @author: chenw
 * @time: 2014-7-22 0022 下午 16:41
 */
@Controller
@RequestMapping("api/query")
public class ApiQueryController extends BaseController {

    @Resource(name = "configInfo")
    private ConfigInfo configInfo;

    @Resource
    private IQueryService queryService;

    @Resource
    private IMattersService mattersService;

    @Resource
    private IVehicleService vehicleService;

    @Resource
    private IJlApiService jlApiService;

    @Resource
    private IWtMemberService wtMemberService;

    /**
     * 重名查询H5
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "name", method = POST)
    public Result duplicationNameQuery(HttpServletRequest request) {

        return queryService.loadRepetitiveName(request);
    }

    /**
     * 重名查询
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "ytName", method = POST)
    public Result ytDuplicationNameQuery(HttpServletRequest request) throws IOException {
        return queryService.ytLoadRepetitiveName(request);
    }



    /***
     * 重名查询
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "getPageWithToken/cmcx", method = POST)
    public void redirectWithToken(HttpServletRequest request, HttpServletResponse response ) throws Exception{
        Result result  = queryService.ytLoadRepetitiveName(request);
        String paraStr = "";
        paraStr += "&countage1=" + ((JSONObject) result.getData()).get("countage1");
        paraStr += "&countage2=" + ((JSONObject) result.getData()).get("countage2");
        paraStr += "&countage3=" + ((JSONObject) result.getData()).get("countage3=");
        paraStr += "&countage4=" + ((JSONObject) result.getData()).get("countage4");
        paraStr += "&countage5=" + ((JSONObject) result.getData()).get("countage5");
        paraStr += "&countage6=" + ((JSONObject) result.getData()).get("countage6");
        paraStr += "&countsex1=" + ((JSONObject) result.getData()).get("countsex1");
        paraStr += "&countsex2=" + ((JSONObject) result.getData()).get("countsex2");
        paraStr += "&countstar3=" + ((JSONObject) result.getData()).get("countstar3");
        paraStr += "&countstar4=" + ((JSONObject) result.getData()).get("countstar4");
        paraStr += "&countstar5=" + ((JSONObject) result.getData()).get("countstar5");
        paraStr += "&countstar6=" + ((JSONObject) result.getData()).get("countstar6");
        paraStr += "&countstar7=" + ((JSONObject) result.getData()).get("countstar7");
        paraStr += "&countstar8=" + ((JSONObject) result.getData()).get("countstar8");
        paraStr += "&countstar9=" + ((JSONObject) result.getData()).get("countstar9");
        paraStr += "&countstar10=" + ((JSONObject) result.getData()).get("countstar10");
        paraStr += "&countstar11=" + ((JSONObject) result.getData()).get("countstar11");
        paraStr += "&countstar12=" + ((JSONObject) result.getData()).get("countstar12");
        paraStr += "&countstar1=" + ((JSONObject) result.getData()).get("countstar1");
        paraStr += "&countstar2=" + ((JSONObject) result.getData()).get("countstar2");
        paraStr += "&count=" + ((JSONObject) result.getData()).get("count");
        String name = request.getParameter("name");
        String link = "https://zwfw.ytga.gov.cn/econsole/resource/static/plugins/1.html?name=" + URLEncoder.encode(name, "UTF-8")+ paraStr;
         response.sendRedirect(link);
    }

    /**
     * 加载车辆类型列表
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "vehicle/cartype", method = GET)
    public Result loadWtCarTypeList(){

        return queryService.loadWtCarTypeList(Constant.JDCHPZL);
    }

    /**
     * 机动车违法查询H5
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "vehicle/illegal", method = POST)
    public Result vehicleIllegalQuery(HttpServletRequest request) {

        return queryService.loadVehicleIllegalList(request);
    }

    /**
     * 机动车违法查询H5非推送
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "vehicle/illegals", method = POST)
    public Result vehicleIllegalQuerys(OffenseVehicleSearchCondition vehicleSearch) {
        Result r = new Result();
        String msg = vehicleSearch.nullOrEmpty();
        if (!Strings.isNullOrEmpty(msg)) {
            return new Result(Result.FAILURE, msg);
        }
        try {
            r = queryService.loadVehicleIllegalLists(vehicleSearch);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return r;
    }


    /**
     * 机动车违法查询
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "ytVehicle/illegals", method = POST)
    public Result ytVehicleIllegalQuerys(OffenseVehicleSearchCondition vehicleSearch) throws IOException {
        Result r = new Result();
        String msg = vehicleSearch.nullOrEmpty();
        if (!Strings.isNullOrEmpty(msg)) {
            return new Result(Result.FAILURE, msg);
        }
        try {
            r = queryService.ytVehicleIllegalLists(vehicleSearch);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return r;
    }


    /**
     * 驾驶证记分查询H5
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "license/points", method = POST)
    public Result licensePointsQuery(HttpServletRequest request) {

        return queryService.loadLicensePointsInfo(request);
    }


    /**
     * 驾驶证记分查询
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "ytLicense/points", method = POST)
    public Result ytLicensePointsQuery(HttpServletRequest request)throws IOException {
        return queryService.ytLicensePointsInfo(request);
    }

    /**
     * 车辆查询
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "vehicle/clcx", method = POST)
    public Result vehicleIllegalclcx(HttpServletRequest request) {
        return queryService.loadVehicleclcxLists(request);
    }

    /**
     * 货车通行证查询
     *
     * @param truckPass 货车通告证实体类
     * @return ModelAndView
     */
    @ResponseBody
    @RequestMapping(value = "pass/truck", method = POST)
    public Result truckPassQuery(@ModelAttribute TruckPass truckPass) throws IOException {
        return mattersService.loadTruckPermitInfo(truckPass.getPassId(), truckPass.getPassCode(), truckPass.getPassword());
    }

    /**
     * 临时通行证查询
     *
     * @param tempPass 通行证唯一吗
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "pass/temp/{temp_pass}", method = GET)
    public Result truckTempPassQuery(@PathVariable("temp_pass") String tempPass) throws IOException {
        return mattersService.loadInterimPermitInfo(tempPass);
    }

    /**
     * 身份证办理进度信息查询H5
     *
     * @param request
     * @return
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value = "progress/idcard", method = POST)
    public Result idCardDealProgressQuery(HttpServletRequest request) throws IOException {
        String idCard = request.getParameter("idCard");
        if (StringUtils.isBlank(idCard)) {
            return new Result(Result.FAILURE, "请输入身份证号");
        }
        /*String pendingId = request.getParameter("pendingId");
        if(StringUtils.isBlank(pendingId)){
            return new Result(Result.FAILURE,"请输入受理编号");
        }*/
        return mattersService.loadIdCardScheduleDetail(idCard);
    }

    /**
     * 办件进度信息查询H5
     *
     * @param request 办件编号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "progress/case", method = POST)
    public Result loadDoScheduleDetail(HttpServletRequest request) throws IOException {
        String case_id = request.getParameter("case_id");
        if (StringUtils.isBlank(case_id)) {
            return new Result(Result.FAILURE, "请输入业务编号");
        }
        return mattersService.loadDoScheduleDetail(case_id);
    }


    /**
     * 网上办件进度信息查询
     *
     * @param request 办件编号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "wsprogress/case", method = POST)
    public Result wscheduleDetail(HttpServletRequest request) throws IOException {
        String case_id = request.getParameter("case_id");
        if (StringUtils.isBlank(case_id)) {
            return new Result(Result.FAILURE, "请输入业务编号");
        }
        return mattersService.wsScheduleDetail(case_id);
    }

    /**
     * 出入境案件办理进度查询H5
     *
     * @param request 案件编号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "entry-exit/case-progress", method = POST)
    public Result caseProgressQuery(HttpServletRequest request) {
        String case_id = request.getParameter("case_id");
        if (StringUtils.isBlank(case_id)) {
            return new Result(Result.FAILURE, "请输入业务编号");
        }
        return queryService.loadCaseProgress(case_id);
    }

    /**
     * 保安员查询H5
     *
     * @param request 办件编号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "bay/info", method = POST)
    public Result loadBayInfoDetail(HttpServletRequest request) throws IOException {
        String idCard = request.getParameter("idCard");
        if (StringUtils.isBlank(idCard)) {
            return new Result(Result.FAILURE, "请输入身份证号");
        }
        String name = request.getParameter("name");
        if (StringUtils.isBlank(name)) {
            return new Result(Result.FAILURE, "请输入姓名");
        }
        String result = "";
        try {
            result = SecurityStaffService.getInstance().getQueryBayxx(idCard, name);
        } catch (Exception e) {

        }
        result = result.trim();
        BayInfo bayInfo = JSONObject.parseObject(result, BayInfo.class);
        if (StringUtils.isNotBlank(result)) {
            return new Result(Result.SUCC, bayInfo, "保安员信息查询成功");
        }
        return new Result(Result.FAILURE, "保安员信息查询失败");
    }

    /**
     * 获取内外网查询消息结果
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "result/gain", method = GET)
    public String queryResultGain(HttpServletRequest request, Model model) {
        String sn = request.getParameter("sn");
        if (StringUtils.isBlank(sn)) {
            model.addAttribute("error", "请输入查询ID");
            return "";
        }
        String action = request.getParameter("action");
        if (StringUtils.isBlank(action)) {
            model.addAttribute("error", "请输入查询接口类别");
            return "";
        }

        Object object = queryService.loadResultGain(sn, action);
        if (null != object) {
            if (action.equals(InQueryServiceInfo.API_001)) {
                //实名认证
                RealNameAuthInfo realNameAuthInfo = (RealNameAuthInfo) object;
                model.addAttribute("realNameAuthInfo", realNameAuthInfo);
                return "query/result_sfzhc";

            } else if (action.equals(InQueryServiceInfo.API_002)) {
                InQueryServiceInfo inQueryServiceInfo = jlApiService.findInQueryBySN(sn);
                OffenseVehicleSearchCondition condition = JSONObject.parseObject(inQueryServiceInfo.getCommand(), OffenseVehicleSearchCondition.class);
                // 车辆违章查询
                List<OffenseVehicleInfo> list = (List<OffenseVehicleInfo>) object;
                List<CarType> carTypelist = (List<CarType>) queryService.loadWtCarTypeList(Constant.JDCHPZL).getData();
                for (CarType carType : carTypelist) {
                    if (condition.getJdccllxbm().equals(carType.getCode())) {
                        condition.setJdccllxbm(carType.getName());
                        break;
                    }
                }
                model.addAttribute("condition", condition);
                model.addAttribute("offenseVehicleList", list);
                return "query/result_jdcwf";

            } else if (action.equals(InQueryServiceInfo.API_003)) {
                // 车辆查询
                List<VehicleItem> list = (List<VehicleItem>) object;
                if (null != list && 0 < list.size()) {
                    model.addAttribute("vehicleItem", list.get(0));
                    return "query/result_cphhc";
                }

            } else if (action.equals(InQueryServiceInfo.API_004)) {
                // 驾驶员查询
                JLDriverInfo jlDriverInfo = (JLDriverInfo) object;
                model.addAttribute("jlDriverInfo", jlDriverInfo);
                return "query/result_jsycx";

            } else if (action.equals(InQueryServiceInfo.API_005)) {
                // 已决在押人员
                List<YjZyPersonInfo> list = (List<YjZyPersonInfo>) object;
                model.addAttribute("yjZyPersonList", list);
                return "query/result_yjzyry";

            } else if (action.equals(InQueryServiceInfo.API_006)) {
                // 重名查询
                NameSakeInfo nameSakeInfo = (NameSakeInfo) object;
                model.addAttribute("nameSakeInfo", nameSakeInfo);
                return "query/result_cmcx";

            } else if (action.equals(InQueryServiceInfo.API_007)) {
                // 驾照查询
                DriverLicenseInfo driverLicenseInfo = (DriverLicenseInfo) object;
                model.addAttribute("driverLicenseInfo", driverLicenseInfo);
                return "query/result_jszjf";

            }
        }
        return "";
    }

    /**
     * 天气预报
     *
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "weather", method = GET)
    public Result weatherInfoQuery() {
        return queryService.loadWeatherForecastInfo();
    }

    /**
     * 车辆交通违章信息查询
     *
     * @return Result
     */
//    @RequestMapping(value = "violation/vehicle", method = POST)
//    public Result trafficeViolationQuery(@ModelAttribute VehicleInfo vehicleInfo) {
//        return queryService.queryTrafficeViolation(vehicleInfo);
//    }
    @ResponseBody
    @RequestMapping(value = "violation/vehicle", method = POST)
    public Result trafficeViolationQueryV2(@ModelAttribute VehicleInfo vehicleInfo) {
        return vehicleService.queryVehicleViolation(vehicleInfo);
    }

    @ResponseBody
    @RequestMapping(value = "violation/vehicle/auth", method = POST)
    public Result trafficeViolationQueryAuth(@ModelAttribute VehicleInfo vehicleInfo, @RequestParam("key") String key, @RequestParam("appkey") String appKey) {
        if (vehicleService.validateAuth(key, appKey)) {
            return vehicleService.queryVehicleViolation(vehicleInfo);
        } else {
            return new Result(Result.FAILURE, "无访问权限");
        }
    }

    /**
     * 驾驶员违章信息查询
     *
     * @param driverInfo 驾驶员信息
     * @return Result
     */
//    @RequestMapping(value = "violation/driver", method = POST)
//    public Result driverInfoQuery(@ModelAttribute DriverInfo driverInfo) {
//        return queryService.queryDriverInfo(driverInfo);
//    }
    @ResponseBody
    @RequestMapping(value = "violation/driver", method = POST)
    public Result driverInfoQueryV2(@ModelAttribute DriverInfo driverInfo) {
        return vehicleService.queryDriverViolation(driverInfo);
    }

    @ResponseBody
    @RequestMapping(value = "violation/driver/auth", method = POST)
    public Result driverInfoQueryAuth(@ModelAttribute DriverInfo driverInfo, @RequestParam("key") String key, @RequestParam("appkey") String appKey) {
        if (vehicleService.validateAuth(key, appKey)) {
            return vehicleService.queryDriverViolation(driverInfo);
        } else {
            return new Result(Result.FAILURE, "无访问权限");
        }
    }

    /**
     * 居住证办理进度信息查询
     *
     * @param idNum 身份证号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "progress/residence/{id_num}", method = GET)
    public Result loadPermitDetailInfo(@PathVariable("id_num") String idNum) throws IOException {
        return mattersService.loadPermitScheduleDetail(idNum);
    }

    /**
     * 居住证办理地点信息查询
     *
     * @param streetName    街道名称
     * @param communityName 社区名称
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "location/permit/{street_name}/{community_name}", method = GET)
    public Result loadPermitOfficeDetail(@PathVariable("street_name") String streetName, @PathVariable("community_name") String communityName) throws IOException {
        return mattersService.loadPermitSiteDetail(streetName, communityName);
    }

    /**
     * 加载全部苏州市局及分局信息
     *
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "police-bureaus", method = GET)
    public Result loadAllBuresau() throws IOException {
        return mattersService.loadAllBureau();
    }

    /**
     * 加载苏州市局及分局科室信息
     *
     * @param bureauId 市局或分局ID
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "bureau-depts/{bureau_id}", method = GET)
    public Result loadAllDepartments(@PathVariable("bureau_id") String bureauId) throws IOException {
        return mattersService.loadDepartments(bureauId);
    }

    /**
     * 分局下所有的派出所
     *
     * @param bureauId 分局id
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "police-stations/{bureau_id}")
    public Result loadPoliceStation(@PathVariable("bureau_id") String bureauId) throws IOException {
        return mattersService.loadPoliceStations(bureauId);
    }

    /**
     * 获取派出所下所有警务室
     *
     * @param officeId 派出所id
     * @return ModelAndView
     */
    @ResponseBody
    @RequestMapping(value = "police-offices/{office_id}")
    public Result loadPoliceOffices(@PathVariable("office_id") String officeId) throws IOException {
        return mattersService.loadPoliceOfficeByStation(officeId);
    }

    /**
     * 加载全部警种列表信息
     *
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "police-catalogs", method = GET)
    public Result loadMatterCatalog() throws IOException {
        return mattersService.loadAllPoliceCatalog();
    }

    @ResponseBody
    @RequestMapping(value = "police-catalogsAll", method = GET)
    public Result loadMatterCatalogAll() throws IOException {
        return mattersService.loadAllPoliceCatalogAll();
    }

    /**
     * 警务室信息
     *
     * @param name 警务室名称
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "office-info", method = POST)
    public Result loadPoliceOfficeInfoByName(@RequestParam("name") String name) throws IOException {
        return mattersService.loadAlarmRoomInfoByName(name);
    }

    /**
     * 案件信息查询
     *
     * @param idCard    身份证号码
     * @param pendingId 办件编号
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "caseinfo", method = POST)
    public Result loadCaseDetail(@RequestParam("idCard") String idCard, @RequestParam("pendingId") String pendingId) throws IOException {
        return mattersService.loadCaseDetail(idCard, pendingId);
    }

    /**
     * 加载全部监控点信息
     * 缓存0.5小时
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "monitors", method = GET)
    public Result loadMonitorsInfo() {
        return queryService.loadMonitorsInfo();
    }

    /**
     * 监控点模糊查询
     * 缓存0.5小时
     * @param address 监控点所在位置名称
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "monitors/search", method = GET)
    public Result loadMonitorInfoByName(@RequestParam(value = "address", required = false) String address) {
        return queryService.loadMonitorsByAddress(address);
    }

    /**
     * 查询监控点照片
     * 缓存0.5小时
     * @param equipmentid 监控点ID
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "road/{equipmentid}", method = GET)
    public Result loadRoadImg(@PathVariable("equipmentid") String equipmentid) {
        return queryService.loadMonitorPicture(super.getLocalHostIP(), equipmentid);
    }

    /**
     * 分页查询监控点照片(微官网)
     *
     * @param pageindex 监控点ID
     * @return Result
     */
    @ResponseBody
    @RequestMapping(value = "road/page/{pageindex}", method = GET)
    public Result loadRoadImages(@PathVariable("pageindex") String pageindex) {
        return queryService.loadRoadImages(getLocalHostIP(), 8, Integer.parseInt(pageindex));
    }

    /**
     * 下载货车临时通行证二维码
     */
    @ResponseBody
    @RequestMapping(value = "passport/qr/{projectguid}", method = GET)
    public Result loadQRImg(@PathVariable("projectguid") String projectguid) {
        return queryService.loadQRImg(super.getLocalHostIP(), projectguid);
    }

    /**
     * 下载货车零时通行证
     */
    @ResponseBody
    @RequestMapping(value = "passport/img/{projectguid}", method = GET)
    public Result loadPassportImg(@PathVariable("projectguid") String projectguid) {
        return queryService.loadPassportImg(super.getLocalHostIP(), projectguid);
    }

    /**
     * 社区民警列表查询H5
     *
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "search", method = POST)
    public Result communityPoliceQuery(HttpServletRequest request) {
        return queryService.loadPolice(request);
    }

    /**
     * 社区民警查询H5
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "search/result/{id}")
    public Result PoliceQuery(@PathVariable("id") String id) {
        return queryService.loadPolicexq(id);
    }

    /**
     * 社区民警查询详情页面跳转
     * @param id
     * @return
     */
    @RequestMapping(value = "search/{id}", method = GET)
    public String PoliceResult(@PathVariable("id") String id, HttpServletRequest request, Model model) {
//        String source = (String) request.getSession().getAttribute("source");
//        if (org.apache.commons.lang.StringUtils.isNotBlank(source)) {
//            model.addAttribute("source", source);
//        }
        model.addAttribute("id", id);
        return "weixin/bmsrv/communityPolice-result";
    }

    /**
     * 留言并发送给民警
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "message")
    public Result SendMessage(HttpServletRequest request) {
        WtMember wtMember = getWxMemberSession();
        if (Objects.isNull(wtMember)) {
            return new Result(Result.FAILURE, "请登录");
        }
        String userName = wtMember.getAliasName();//发送人 姓名
        String userMobile = wtMember.getUserName();//发送人 电话号码
        String policeMobile = request.getParameter("phone");//警员 手机号
        String content = request.getParameter("message");//短信内容
        content = content + String.format(Constant.COMMUNITY_POLICE_MSG, userName, userMobile);
        if (Objects.isNull(policeMobile)) {
            return new Result(Result.FAILURE, "发送失败，警员无手机号");
        } else {
            return queryService.sendMessage(policeMobile, content);
        }
    }
}
